01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.lucene.store.jdbc.dialect;
18:
19: /**
20: * A PostgreSQL dialect.
21: *
22: * @author kimchy
23: */
24: public class PostgreSQLDialect extends Dialect {
25:
26: /**
27: * PostreSQL supports select ... for update.
28: */
29: public boolean supportsForUpdate() {
30: return true;
31: }
32:
33: /**
34: * PostgreSQL supports transactional scoped blobs.
35: */
36: public boolean supportTransactionalScopedBlobs() {
37: return true;
38: }
39:
40: /**
41: * PostrgreSQL supports a table exists query.
42: */
43: public boolean supportsTableExists() {
44: return true;
45: }
46:
47: public String sqlTableExists(String catalog, String schemaName) {
48: if (schemaName == null || schemaName.length() == 0) {
49: schemaName = "public";
50: }
51: return "select tablename from pg_tables where schemaname = '"
52: + schemaName + "' and lower(tablename) = ?";
53: }
54:
55: public boolean supportsCurrentTimestampSelection() {
56: return true;
57: }
58:
59: public boolean isCurrentTimestampSelectStringCallable() {
60: return false;
61: }
62:
63: public boolean useInputStreamToInsertBlob() {
64: return false;
65: }
66:
67: public String getCurrentTimestampSelectString() {
68: return "select now()";
69: }
70:
71: public String getVarcharType(int length) {
72: return "varchar(" + length + ")";
73: }
74:
75: public String getBlobType(long length) {
76: return "oid";
77: }
78:
79: public String getNumberType() {
80: return "int4";
81: }
82:
83: public String getTimestampType() {
84: return "timestamp";
85: }
86:
87: public String getCurrentTimestampFunction() {
88: return "current_timestamp";
89: }
90:
91: public String getBitType() {
92: return "bool";
93: }
94: }
|