Index: src/backend/catalog/catalog.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/catalog/catalog.c,v retrieving revision 1.32 diff -c -r1.32 catalog.c *** src/backend/catalog/catalog.c 2000/04/12 17:14:55 1.32 --- src/backend/catalog/catalog.c 2000/06/11 06:15:45 *************** *** 45,50 **** --- 45,81 ---- return path; } + if ((strncmp(relname, "xin", 3) == 0) && (strlen(relname) > 4)) + if ((relname[3] == 'v') || (relname[3] == 'x')) { + /* LO's are resided in Database dir */ + char *err; + Oid oid; + size_t bufsize; + + oid = strtol(relname + 4, &err, 10); + if (*err == '\0') { + int pw = 0; + Oid s_oid = oid; + while (s_oid != 0) { + pw++; + s_oid /= LO_HASH_SIZE; + } + s_oid = oid / LO_HASH_SIZE; + bufsize = strlen(relname) + pw * (LO_HASH_POWER + 1) + 4; + path = (char *) palloc(sizeof(char) * bufsize); + path[0] = relname[3]; + path[1] = SEP_CHAR; + path[2] = 0; + pw = 2; + while (s_oid != 0) { + snprintf(path + pw, LO_HASH_POWER + 2, "%03d%c", s_oid % LO_HASH_SIZE, SEP_CHAR); + pw += (LO_HASH_POWER + 1); + s_oid /= LO_HASH_SIZE; + } + snprintf(path + pw, bufsize - pw, "%s", relname); + return path; + } + } /* * If it is in the current database, assume it is in current working * directory. NB: this does not work during bootstrap! Index: src/backend/storage/large_object/inv_api.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v retrieving revision 1.69 diff -c -r1.69 inv_api.c *** src/backend/storage/large_object/inv_api.c 2000/06/05 07:28:45 1.69 --- src/backend/storage/large_object/inv_api.c 2000/06/11 06:15:50 *************** *** 34,39 **** --- 34,41 ---- #include "utils/fmgroids.h" #include "utils/relcache.h" + #include + /* * Warning, Will Robinson... In order to pack data into an inversion * file as densely as possible, we violate the class abstraction here. *************** *** 96,101 **** --- 98,106 ---- Oid classObjectId[1]; char objname[NAMEDATALEN]; char indname[NAMEDATALEN]; + Oid s_oid; + int pw = 0; + size_t dirsize; /* * add one here since the pg_class tuple created will have the next *************** *** 132,137 **** --- 137,180 ---- BYTEAOID, -1, 0, false); + s_oid = file_oid; + while (s_oid != 0) { + pw++; + s_oid /= LO_HASH_SIZE; + } + dirsize = pw * (LO_HASH_POWER + 1) + 2; + + { + char dirname[dirsize]; + struct stat st; + + dirname[1] = 0; + pw = 1; + s_oid = file_oid; + for(; ; ) { + dirname[0] = 'v'; + if (stat(dirname, &st) == -1) { + if (errno == ENOENT) { + if (mkdir(dirname, S_IRWXU) != 0) + elog(ERROR, "lo_create: unable to create large object directory '%s': %s", dirname, strerror(errno)); + } else + elog(ERROR, "lo_create: unable to stat large object directory '%s': %s", dirname, strerror(errno)); + } + dirname[0] = 'x'; + if (stat(dirname, &st) == -1) { + if (errno == ENOENT) { + if (mkdir(dirname, S_IRWXU) != 0) + elog(ERROR, "lo_create: unable to create large object directory '%s': %s", dirname, strerror(errno)); + } else + elog(ERROR, "lo_create: unable to stat large object directory '%s': %s", dirname, strerror(errno)); + } + s_oid /= LO_HASH_SIZE; + if (s_oid == 0) + break; + snprintf(dirname + pw, LO_HASH_POWER + 2, "%c%02d", SEP_CHAR, s_oid % LO_HASH_SIZE); + pw += (LO_HASH_SIZE + 1); + } + } /* * First create the table to hold the inversion large object. It will * be located on whatever storage manager the user requested. Index: src/include/config.h.in =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/config.h.in,v retrieving revision 1.117 diff -c -r1.117 config.h.in *** src/include/config.h.in 2000/06/09 16:03:07 1.117 --- src/include/config.h.in 2000/06/11 06:15:53 *************** *** 174,179 **** --- 174,186 ---- */ #define DEFAULT_MAX_EXPR_DEPTH 10000 + /* + * LO_HASH_SIZE determines max amount of large objects in one dir. + * LO_HASH_POWER is the exponent of LO_HASH_SIZE with base 10. + */ + + #define LO_HASH_SIZE 1000 + #define LO_HASH_POWER 3 /* *------------------------------------------------------------------------